package com.codesuc.aichat.exception;

import com.codesuc.aichat.enums.CodeSucErrorEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @Description 自定义全局异常
 * @Author Mr.Zhang
 * @Date 2025/8/3 20:48
 * @Version 1.0
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class CodeSucException extends RuntimeException {

    /**
     * 错误码
     */
    private int code;

    /**
     * 错误信息
     */
    private String message;

    public CodeSucException(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public CodeSucException(CodeSucErrorEnum codeEnum) {
        super(codeEnum.getMessage());
        this.code = codeEnum.getCode();
        this.message = codeEnum.getMessage();
    }
}
